<template>
	<div class="lay-blog">
		<div class="header">
			<div class="header-wrap">
				<h1 class="logo pull-left">
					<a href="./">
						<img src="static/logo.png" />
					</a>
				</h1>
				<form class="layui-form blog-seach pull-left" action="">
					<div class="layui-form-item blog-sewrap">
						<div class="layui-input-block blog-sebox">
							<input type="text" name="title" lay-verify="title" autocomplete="off" class="layui-input">
						</div>
					</div>
				</form>
				<div class="blog-nav pull-right">
					<ul class="layui-nav pull-left">
						<li class="layui-nav-item" v-bind:class="{'layui-this':1}"><a href="#/pages/index/index">首页</a></li>
						<li class="layui-nav-item"><a href="#/pages/index/message">留言</a></li>
						<li class="layui-nav-item"><a href="#/pages/index/about">关于</a></li>
					</ul>

				</div>
				<div class="mobile-nav pull-right" id="mobile-nav">

				</div>
			</div>

		</div>
		<div class="container-wrap">
			<div class="container container-message container-details">
				<div class="contar-wrap">
					<div class="item">
						<div class="item-box  layer-photos-demo1 layer-photos-demo">
							<h3><a>{{title}}</a></h3>
							<h5>发布于：<span>{{dateFormat(add_time)}}</span></h5>
							<p v-html="content">
								{{content}}
							</p>

							<div class="count layui-clear">
								<span class="pull-left">阅读 <em>{{views}}</em></span>

							</div>
						</div>
					</div>

				</div>
			</div>
		</div>
		<myfooter></myfooter>
	</div>
</template>

<script>
	import api_url from '@/common/config.js'
	import myfooter from '../public/footer.vue';
	export default {
		data() {
			return {
				title: "文章标题",
				content: "文章内容",
				add_time: "2020-12-15",
				id: '',
				views: '',
			}
		},
		onLoad(e) {
			uni.showLoading({
				title: '加载中'
			});
			this.id = e.id
			let _this = this;
			let id = this.id;
			uni.request({
				url: api_url + '/api.php?route=articleInfo&gid=' + id,
				header: {
					'content-type': "application/x-www-form-urlencoded" //自定义请求头信息
				},
				method: 'GET',
				// 成功回调
				success: (res) => {
					uni.hideLoading();
					console.log('返回值', res.data)
					_this.title = res.data.data.title;
					_this.add_time = res.data.data.date;
					_this.content = res.data.data.content;
					_this.views = res.data.data.views;
				}

			})

		},
		components: {
			myfooter: myfooter
		},
		methods: {
			dateFormat: function(time) {
				var time = time * 1000;
				var date = new Date(time);
				var year = date.getFullYear();
				var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
				var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
				var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
				var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
				var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
				// 拼接
				return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
			},
			addClass: function(index, event) {
				this.current = index;

				//获取点击对象      
				var el = event.currentTarget;
				//alert("当前对象的内容："+el.innerHTML);
			}

		}
	}
</script>

<style>

</style>
